<?php

function time_difference($begin,$end){//计算时间差函数
	$res = '';
	$sec = ((!strtotime($end))?time():strtotime($end))-((!strtotime($begin))?0:strtotime($begin));
	$days = floor($sec / (24*3600));  
	$sec = $sec % (24*3600);  
	$hours = floor($sec / 3600);  
	$remainSeconds = $sec % 3600;  
	$minutes = floor($remainSeconds / 60);  
	$seconds = intval($sec - $hours * 3600 - $minutes * 60);  
	
	if($days != 0)$res = $days."天";
	if($hours != 0)$res .= $hours."小时";
	if($minutes != 0)$res .= $minutes."分";
	if($seconds != 0)$res .= $seconds."秒";
	return "用时：".$res; 
}

?>

	<?php if($m == 0){
	echo "<div style='margin:10px;'>";
	?>
	<div style="font-size:16px; margin-bottom:10px;">流水号：<?php echo $workflow_row_data->run_id.'&nbsp;&nbsp;名称：'.$workflow_row_data->run_title;?></div>
    <table style="border-collapse:collapse;" bordercolor="#999999" cellSpacing="0" width="100%" align="center" bgColor="#ffffff" border="1">
    <?php foreach ($flowchart as $value) { ?>
        <tr>
            <td width=100 style="text-align:center; line-height:40px;">第 <font style='color:#F30;font-weight:bold'><?php echo $value->ps_id?></font> 步</td>
            <td style="padding:5px;">
            <?php
            echo "<font style='color:#F30;font-weight:bold'>".$value->ps_username.' 主办</font>';
            echo "<font style='color:#390'> [";
            switch($value->ps_flag){
                case 1:
                    echo '未接收办理';  
                    break;
                case 2:
                    echo '办理中';  
                    break;
                case 3:
                    echo '已转交';  
                    break;
				case 4:
                    echo '已办结';  
                    break;		
            }
            ?>
            <?php
			//echo strtotime($value->ps_datetime).'-'.$value->deliver_datetime;
            echo time_difference($value->create_datetime,$value->deliver_datetime);//显示所用时间自定义函数
			echo "]</font>";
            echo "<br>开始时间：".$value->ps_datetime."&nbsp;&nbsp;&nbsp;&nbsp;结束时间：".$value->deliver_datetime." ";
            ?>
            </td>
        </tr>
    <?php }
	echo "</table></div>";
	}else{
	?>	
	<table style="border-collapse:collapse;" cellSpacing="0" width="100%" border="0" cellpadding="10">
    <?php foreach ($flowchart as $value) { ?>
		<tr style="border-bottom:1px dotted #6699CC;">
            <td width=100 >
            	 第 <font style='color:#F30;font-weight:bold'><?php echo $value->ps_id?></font> 步 <?php echo time_difference($value->ps_datetime,$value->deliver_datetime);?><br>
            	办理人：
                <?php
				echo $value->ps_username;
				switch($value->ps_flag){
					case 0:
						echo '（已办结）';  
						break;		
					case 1:
						echo '（未接收办理）';  
						break;
					case 2:
						echo '（办理中）';  
						break;
					case 3:
						echo '（已转交）';  
						break;
				}
				echo "<br>开始时间：".$value->ps_datetime."<br>结束时间：".$value->deliver_datetime." ";
				?>
            </td>
        </tr>
	<?php
		}
		echo "</table>";
	}
	?>
